package whu.o2o.View;

import android.app.Activity;
import android.app.ProgressDialog;
import android.content.Context;

public class LoadDialog {

	public static ProgressDialog mDialog;
	public static Activity mContext;

	public static void showDailog(Context context) {
		if (context == null) {
			return;
		}

		mContext = (Activity) context;
		if (mContext.isFinishing()) {
			return;
		}

		if (mDialog != null && mDialog.isShowing()) {
			return;
		}

		mDialog = new ProgressDialog(mContext);
		mDialog.setMessage("请稍候");
		mDialog.setIndeterminate(true);
		mDialog.setCancelable(true);
		mDialog.show();
	}
	

	public static void showDailog(Context context, CharSequence message) {
		if (context == null) {
			return;
		}

		mContext = (Activity) context;
		if (mContext.isFinishing()) {
			return;
		}

		if (mDialog != null && mDialog.isShowing()) {
			return;
		}

		mDialog = new ProgressDialog(mContext);
		mDialog.setMessage(message);
		mDialog.setIndeterminate(true);
		mDialog.setCancelable(true);
		mDialog.show();
	}

	public static void closeDialog() {
		if (mDialog != null && mDialog.isShowing() && mContext != null && !mContext.isFinishing()) {
			mDialog.dismiss();
		}
	}
}
